<?php

namespace App\Jobs\Push;

use Exception;
use App\Models\User;
use App\Facades\Push;
use Illuminate\Bus\Queueable;
use Illuminate\Support\Facades\Log;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

/**
 * 删除用户所有标签
 *
 * Date: 2018/6/4
 * @author George
 * @package App\Jobs\Push
 */
class ClearUserTags implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $user;

	/**
	 * ClearUserTags constructor.
	 * @param $user
	 */
	public function __construct(User $user)
	{
		$this->user = $user;
	}


	/**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
		try {
			Push::device()->clearTags($this->user->registration_id);
		} catch (Exception $exception) {
			Log::error($exception);
		}
	}
}
